using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication2.Models.Mapping
{
    public class ParentMap : EntityTypeConfiguration<Parent>
    {
        public ParentMap()
        {
            // Primary Key
            this.HasKey(t => t.ACCT);

            // Properties
            this.Property(t => t.ACCT)
                .IsRequired()
                .HasMaxLength(40);

            this.Property(t => t.File_Primary_Key)
                .HasMaxLength(10);

            // Table & Column Mappings
            this.ToTable("Parent");
            this.Property(t => t.ACCT).HasColumnName("ACCT");
            this.Property(t => t.File_Primary_Key).HasColumnName("File Primary Key");

            // Relationships
            this.HasRequired(t => t.Acct1)
                .WithOptional(t => t.Parent1);

        }
    }
}
